package com.oocl.task20170718.entity;

import java.io.Serializable;
import java.util.Date;
import java.util.HashMap;
import java.util.Map;

public class Book implements Serializable{
	/**
	 * serialVersionUID in default
	 */
	private static final long serialVersionUID = 1L;
	private Integer id;
	private String name;
	private Date publishTime;
	private String author;
	private Double price;
	private Boolean old;//新书与否
	private String publisher;
	
	public static final String KEY_NAME = "name";
	public static final String KEY_PUBLISHTIME = "publishTime";
	public static final String KEY_AUTHOR = "author";
	public static final String KEY_PRICE = "price";
	public static final String KEY_OLD = "old";
	public static final String KEY_PUBLISHER = "publisher";
	
	private static final String VAL_NAME = "name=?,";
	private static final String VAL_PUBLISHTIME = "pub_date=?,";
	private static final String VAL_AUTHOR = "author=?,";
	private static final String VAL_PRICE = "price=?,";
	private static final String VAL_OLD = "is_new=?,";
	private static final String VAL_PUBLISHER = "publisher=?,";
	
	private static Map<String,String> mappingMap=new HashMap<String, String>();
	static{
		mappingMap.put(KEY_NAME, VAL_NAME);
		mappingMap.put(KEY_PUBLISHTIME, VAL_PUBLISHTIME);
		mappingMap.put(KEY_AUTHOR, VAL_AUTHOR);
		mappingMap.put(KEY_PRICE, VAL_PRICE);
		mappingMap.put(KEY_OLD, VAL_OLD);
		mappingMap.put(KEY_PUBLISHER, VAL_PUBLISHER);
	}
	
	
	public static Map<String, String> getMappingMap() {
		return mappingMap;
	}
	@Override
	public String toString() {
		return "Book [id=" + id + ", name=" + name + ", publishTime="
				+ publishTime + ", author=" + author + ", price=" + price
				+ ", old=" + old + ", publisher=" + publisher + "]";
	}
	//constructor with full attr
	public Book(Integer id, String name, Date publishTime, String author,
			Double price, Boolean old, String publisher) {
		super();
		this.id = id;
		this.name = name;
		this.publishTime = publishTime;
		this.author = author;
		this.price = price;
		this.old = old;
		this.publisher = publisher;
	}
	//constructor with no attr
	public Book() {
		super();
	}
	//get set
	public Integer getId() {
		return id;
	}
	public void setId(Integer id) {
		this.id = id;
	}
	public String getName() {
		return name;
	}
	public void setName(String name) {
		this.name = name;
	}
	public Date getPublishTime() {
		return publishTime;
	}
	public void setPublishTime(Date publishTime) {
		this.publishTime = publishTime;
	}
	public String getAuthor() {
		return author;
	}
	public void setAuthor(String author) {
		this.author = author;
	}
	public Double getPrice() {
		return price;
	}
	public void setPrice(Double price) {
		this.price = price;
	}
	public Boolean getOld() {
		return old;
	}
	public void setOld(Boolean old) {
		this.old = old;
	}
	public String getPublisher() {
		return publisher;
	}
	public void setPublisher(String publisher) {
		this.publisher = publisher;
	}
	
}
